﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XSTDZ.ERP.Application.DataContracts;
using XSTDZ.ERP.Core.Extentions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using XSTDZ.ERP.Application;
using XSTDZ.ERP.Infrastructure;  

namespace XSTDZ.ERP.WebApp.Models
{
    /// <summary>
    /// 入库单
    /// </summary>
    public class ProductInBill
    {
        public bool ValidateCode(string validateCode)
        {
            return true;
        }
        //根据指定的页面字段名称，获得相应的GUID值
        public Guid GetRequestFormValues(HttpContextBase context,string fileName)
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                if (context.Request.Form[fileName] != null)
                {
                    Guid wareHourseId;
                    if (Guid.TryParse(context.Request.Form[fileName].ToString(), out wareHourseId))
                    {
                        return wareHourseId;
                    }
                }
            }
            return Guid.Empty;
        }

        public IList<ProductInBillDetailDto> GetProductItems(string jsons)
        {
            if (string.IsNullOrEmpty(jsons))
            {
                return null;
            }
            try
            {
                return JsonConvert.DeserializeObject<List<ProductInBillDetailDto>>(jsons);  
            }
            catch (Exception)
            {
                return null;
            }
           
        }

     
    }
}